<!--
 /**
 * Author: hongChengHao
 * Date: 2022-07-26 14:44
 * Desc: 昵称弹窗 NickPop
 */
-->
<template>
  <view class="nick-pop">
    <u-modal
      negative-top="220"
      :show="currentValue"
      title="昵称"
      show-cancel-button
      @confirm="onSave"
      @cancel="onClose"
    >
      <view class="nick-pop__ipt">
        <!-- #ifndef  MP-WEIXIN  -->
        <u-input v-model="nickName" :border="false" clearable></u-input>
        <!-- #endif-->
        <!-- #ifdef MP-WEIXIN -->
        <u-input
          v-model="nickName"
          type="nickname"
          :border="false"
          clearable
        ></u-input>
        <!-- #endif-->
      </view>
    </u-modal>
  </view>
</template>
<script>
  import { Base64 } from 'js-base64'
  export default {
    name: 'NickPop',
    props: {
      value: {
        type: Boolean,
        default: false
      },
      obj: {
        type: Object,
        default: () => {
          return {}
        }
      }
    },
    data() {
      return {
        nickName: this.obj.nickName || ''
      }
    },
    methods: {
      onSave() {
        console.log(this.nickName)
        this.$emit('setMemberData', { nickName: Base64.encode(this.nickName) })
        this.onClose()
      },
      onClose() {
        this.$emit('input', false)
      }
    },
    computed: {
      currentValue: {
        get() {
          return this.value
        },
        set(v) {
          this.$emit('input', v)
        }
      }
    }
  }
</script>
<style lang="scss" scoped>
  .nick-pop {
    &__ipt {
      border-bottom: 1upx solid #eee;
    }
  }
</style>
